package main

import (
	"encoding/json"
	"fmt"
	"strings"
)

func main() {
	strToArray()
}

/**
  字符串以逗号分割成数组
*/
func strToArray() {
	str := "a,b,c"
	arry := strings.Split(str, ",")

	for i := 0; i < len(arry); i++ {
		fmt.Println("i=", i, arry[i])
	}

	arrByte, _ := json.Marshal(arry)
	fmt.Println(string(arrByte))
}
